<!DOCTYPE html PUBLIC "-//W3C//XHTML 1.0 Transitional" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>Core Attack Code</title>
		<meta name="keyword" content="POL, EScript, documentation, Ultima Online, UO, packets, client, ultima online client, emulator" />
		<meta name="description" content="Penultima Online Documentation website." />
		<meta name="Author" content="Racalac, Rykard" />
		<meta name="Generator" content="POL Doc-o-matic" />
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<link href="style.css" rel="stylesheet" type="text/css"  media="all"  />
	</head>
	<script language="JavaScript1.2" type="text/javascript">
function ExpandContract(s) {
  var bulletE = document.getElementById("bullet_"+s);
  var spanE = document.getElementById("span_"+s);
  var Expanded = bulletE.innerHTML;

  if(Expanded == '[+]') {
    spanE.style.display = 'block';
    bulletE.innerHTML = '[-]';
  }
  else { 
    spanE.style.display = 'none'; 
    bulletE.innerHTML = '[+]';
  }
}
</script>

<body>
<div class="container"><div id="doc-mini-header">
<div class="doc-home"><a href="index.html">
            Home
				  </a></div>
<h1>Pseudocode for the core combat system.</h1>
<b>
					Last Modified:
					02/10/2009</b>
</div></div><div id="main"><div class="container"><div class="doc-mainbox"><pre><code>
if( attackhook )
  call hook
  if hook returned 1, exit
endif

if( weapon is projectile )
  try to comsume projectile
  if none, exit
exit

repsys effects

if( weapon is projected )
  play sound and animations
else
  play attack anim
endif

if( combat advancement hook exists )
  call it
else
  THE CORE DOESN'T ADVANCE ANY SKILLS
endif

hit_chance = (weapon_attribute + 50.0) / (2.0 * opponent_weapon_attribute + 50.0)
hit_chance += hitchance_mod * 0.001
hit_chance -= opponent_evasionchance_mod * 0.001

if( random_float(1.0) &lt; hitchance )
  play hit sounds and anims
  damage weapon (1 in 100 chance to lose 1 hp)

  damage = random_weapon_die_damage
  damage_multiplier = tactics + 50
  damage_multiplier += strength * 0.2
  damage_multiplier *= 0.01
  damage *= damage_multiplier

  if( opponent has shield )
    call parry advancement hook

    parry_chance = opponent_parry_skill / 200.0
    if( random_float(1.0) &lt; parry_chance )
      display parry success
      damage -= opponent_shield_ar
    endif
  endif

  if( weapon has no hit script )
    choose armor piece hit based on zone coverage percentage
    blocked = armor piece ar + character ar_mod
    absorbed = blocked / 2
    blocked -= absorbed
    absorbed += random_int(blocked+1)
    damage -= absorbed
    if( damage &gt;= 2.0 )
       damage *= 0.5
    endif
    1 in 100 chance for armor piece to lose 1 hp
    play hit animation
    applydamage(damage)
  else
    choose armor piece hit based on zone coverage percentage
    calc base &amp; raw damage (exactly like above if no hit script)
    run hit script
    (Core doesn't damage armor if hitscript, do it in the script)
  endif
else
  play weapon miss sound
  call hitmiss hook
endif
</code></pre></div></div></div>

<div id="footer">
	<div class="container">
    <p >
      If you <i>know</i> if any information is incorrect on these pages, mail your corrections to polteam@polserver.com
    </p>
    <p >
      Copyright &copy;2003-2009 David Carpman and POL Development Team, all rights reserved. DO NOT REPRODUCE, MIRROR, ALTER, SPINDLE, MUTILATE, OR SIT ON.
    </p>
    </div>
    </div>
    </body>
    </html>
   